//
//  ProfileView.swift
//  casdon_swiftUI
//
//  Created by ww on 2025/4/14.
//

import SwiftUI

struct LifeCircleView: View {
    @StateObject var viewModel = LifeCircelViewModel()
    private let menuTitles = [LocalizedStringKey("Follow"),
                              LocalizedStringKey("Recommended"),
                              LocalizedStringKey("Lifestyle"),
                              LocalizedStringKey("Services"),
                              LocalizedStringKey("Food")]
    

    init()
    {
        _ = [AnyView(FlowView(viewModel: viewModel)),
                         AnyView(FlowView(viewModel: viewModel)),
                         AnyView(FlowView(viewModel: viewModel)),
                         AnyView(FlowView(viewModel: viewModel)),
                         AnyView(FlowView(viewModel: viewModel))]
    }
    var body: some View {
        ZStack{
            VStack {
                LifeCircleNavigationBar(viewModel: viewModel)
                SlidingMenuView().padding(.top, -8) // bug,需要上移8，才能严丝合缝
                Spacer()
            }
           
        }.background(
            Image("home_bg")
                .resizable()

                .edgesIgnoringSafeArea(.all)
        )
        
    }
}

struct LifeCircleNavigationBar: View {
    @ObservedObject var viewModel: LifeCircelViewModel
    var body: some View {
            
                HStack {
                    Text("life circle")
                        .foregroundColor(AppColors.Gy1)
                        .font(.system(size: 18))
                        .bold()
                        .padding(.leading, 12)
                    
                    Spacer()
                    
                    HStack {
                        Button(action: {
                           // viewModel.enterSearch()
                        }, label: {
                            Image("ic_search")
                                .resizable()
                                .scaledToFit()
                                .frame(width: 24, height: 24)
                                .foregroundColor(AppColors.Brand3)
                        
                        }).padding(.trailing, 16)
                        
                        Button(action: {
//                            viewModel.enterAdd()
                        }, label: {
                            Image("add")
                                .resizable()
                                .scaledToFit()
                                .frame(width: 24, height: 24)
                        }).padding(.trailing, 12)
                    }
                }
                .frame(height: 44)
         
    }
}

